<template>
	<view>
		<view class="loading-more" v-show="!listnull" @click="goMore">{{loadtxt}}</view>
		<view class="null" v-show="listnull" >
			<slot name="null"></slot>
		</view>
	</view>
</template>

<script>
	var that;
	import {
	    mapState
	} from 'vuex'
	export default {
		data() {
			return {
				loadtxt:"正在加载中..."
			};
		},
		props:{
			loadtype:{
				type:[String,Number],
				default:0
			},
			listnull:{
				type:Boolean,
				default:false
			},
			listData:Array,
			text0:String,
			text1:String,
			text2:String,
		},
		created(){
			that=this;
		},
		mounted(){
			// this.getloadMoreH()
		},
		computed:
			mapState({
				i18n(){
					return this.$t('product')
				},
				hasLogin(state){
					return state.hasLogin==""?false:true
				},
				hasNetwork(state){
					return state.isConnected
				},
			}),
		methods:{
			getloadMoreH(){
				var moreheight;
				let body = uni.createSelectorQuery().select(".loading-more");
				body.boundingClientRect(function(res){
					that.moreheight=res.height;
					moreheight=res.height;
				}).exec()
				return moreheight;
			},
			goMore(){
				this.$emit('gopage')
			}
		},
		watch:{
			loadtype(newValue,oldValue){
				let text0=this.text0;
				let text1=this.text1;
				let text2=this.text2;
				if(this.loadtype==0){
					this.loadtxt=text0?text0:'正在加载中...';
				}
				else if(this.loadtype==1){
					this.loadtxt=text1?text1:'正在加载中...';//正在加载中...
				}
				else if(this.loadtype==2){
					if(this.hasLogin){
						this.loadtxt=text2?text2:"—————— 已经到底了哦 ——————";
					}else{
						this.loadtxt=text2?text2:"登录查看更多"
					}
				}
			},
			hasLogin(newValue,oldValue){
				let text2=this.text2;
				if(this.loadtype==2){
					if(newValue){
						this.loadtxt=text2?text2:"—————— 已经到底了哦 ——————";
					}else{
						this.loadtxt=text2?text2:"登录查看更多"
					}
				}
			}
		}
	}
</script>

<style>
	.loading-more{
		line-height:100upx;color: #bbb;height: 100upx;font-size: 28upx;
	}
</style>
